<!--
 * @FilePath     : /study_code/vue2.x/slot-parent.html
 * @Description  : 插槽访问父组件作用域数据
 * @Date         : 2025-05-02 20:22:17
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-05-02 20:22:18
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="" />
  </head>
  <body>
    <div id="app">
      <user-component>插槽使用父组件作用域数据：{{ user.name }}</user-component>
    </div>

    <script src="/vue/dist/vue.min.js"></script>
    <script src="./common.js"></script>
    <script>
      Vue.component('user-component', {
        template: `
          <button>
            <slot></slot>
          </button>
          `,
      })

      var vm = new Vue({
        el: '#app',
        data: function () {
          return {
            user: {
              name: 'lutut',
            },
          }
        },
      })
    </script>
  </body>
</html>
